package com.yanqu.road.server.cmd.system;

import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.pb.server.ServerProto;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.manger.ServerListMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;

@Cmd(code = Protocol.S_CONFIG_VERSION, desc = "获取配置版本")
public class ConfigVersionCmd extends AbstractCommand {

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {

		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

	}

	@Override
	public void sendData(GamePlayer player) {
		ServerProto.ConfigVersionRespMsg.Builder respMsg = ServerProto.ConfigVersionRespMsg.newBuilder();
		respMsg.setConfigVersion(GameConfig.CONFIG_VERSION);
		if (ServerListMgr.isWhiteUser(player.getIp(), player.getUserInfo().isAdmin(), player.getUserInfo().getPlatformUserId())) {
			respMsg.setCodeVersion(GameServer.getInstance().getBackendVersion());
		}
		player.sendPacket(Protocol.U_CONFIG_VERSION, respMsg);
	}

}
